package com.phil.tuangou.adapter;

import java.util.List;
import java.util.zip.Inflater;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.phi.tuangou.bean.LashouDetailBean;
import com.phil.tuangou.main.activtiy.R;

public class InfoAdapter extends BaseAdapter {

	private List<LashouDetailBean> list;
	private LayoutInflater inflater;

	public InfoAdapter(List<LashouDetailBean> list, Context context) {
		this.list = list;
		this.inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = inflater.inflate(com.phil.tuangou.main.activtiy.R.layout.infoadapterlayout, null);
			holder = new ViewHolder();
			holder.infoadapter_goods_title_TV = (TextView)convertView.findViewById(R.id.infoadapter_goods_title);
			holder.infoadapter_goods_rules_TV = (TextView)convertView.findViewById(R.id.infoadapter_goods_rules);
			holder.infoadapter_goods_value_TV = (TextView)convertView.findViewById(R.id.infoadapter_goods_value);
			holder.infoadapter_goods_price_TV = (TextView)convertView.findViewById(R.id.infoadapter_goods_price);
			convertView.setTag(holder);
		} else{
			 holder = (ViewHolder) convertView.getTag();
		}
		LashouDetailBean bean = list.get(position);
		System.out.println("title "+bean.getGoods_title());
		holder.infoadapter_goods_title_TV.setText(bean.getGoods_title());
		holder.infoadapter_goods_rules_TV.setText(Html.fromHtml(bean.getGoods_rules()));
		holder.infoadapter_goods_value_TV.setText(""+bean.getGoods_value());
		
		holder.infoadapter_goods_price_TV.setText(""+bean.getGoods_price());
		
		return convertView;
	}

	static class ViewHolder {
		TextView infoadapter_goods_title_TV;
		TextView infoadapter_goods_rules_TV;
		TextView infoadapter_goods_value_TV;
		TextView infoadapter_goods_price_TV;
	}

}
